<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <title>收货地址</title>
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/personal/adress.css">
    <script src="../../js/jquery-2.2.3.min.js"></script>
    <script src="../../js/rem.js"></script>
    <script src="../../js/common.js"></script>


    <script src="../detail/layer-v3.1.1/layer/layer.js"></script>
    <script src="../detail/js/vue.min.js"></script>
    <script src="../detail/js/vue-resource.min.js"></script>
</head>
<body style="background-color: #F5F5F5">
<div id="app">
    <div class="head">
        <div class="h-left" @click="tuTo"></div>
        <div class="h-middle">收货地址</div>
        <div class="h-right" @click="AdAddress">新增</div>
    </div>
    <div style="height: .44rem;"></div>
    <!--<div class="container">-->
        <!--<div class="cont">-->
            <!--<p class="cont-p">徐萌萌 <span class="cont-tel">177  8771 9991</span></p>-->
            <!--<div style="margin-top: .12rem">-->
                <!--<img src="../../img/address.png" class="addressImg" alt="">-->
                <!--<span class="cont-sp">北京市通州区梨园云锦东路时尚街区东区5号楼902室</span>-->
            <!--</div>-->

        <!--</div>-->
        <!--<input type="checkbox" class="inpcex"><span class="inp-sp">设为默认</span>-->
    <!--</div>-->
    <div class="container" v-for="item in list" :data-id='item.addressId' @click="toAddress">
        <div class="cont">
            <p class="cont-p">姓名：{{item.userName}} <span class="cont-tel">手机号：{{item.userPhone}}</span></p>
            <div style="margin-top: .12rem">
                <img src="../../img/address.png" class="addressImg" alt="">
                <span class="cont-sp" :data-addrss='item.userAddressName'>{{item.userAddressName}}</span>
            </div>

        </div>
        <!-- <input type="checkbox" class="inpcex"><span class="inp-sp">设为默认</span> -->
        <!-- <div class="bjBox" style="margin-right: .15rem"> -->
            <!-- <img src="../../img/delete.png" class="bjImg" alt="">
            <span class="bj-sp">删除</span> -->
        <!-- </div> -->
        <!-- <div class="bjBox" style="margin-right: .09rem"> -->
            <!-- <img src="../../img/bianji.png" class="bjImg" alt="">
            <span class="bj-sp">编辑</span> -->
        <!-- </div> -->
		
    </div>
</div>
<script>
    var app = new Vue({
        el:'#app',
        data:{
            list:[]
        },
        mounted(){
            this.$http.post(SURL + '/api/xlsusersaddress/selectAddressByuserId',{userId:localStorage.getItem('userId')},{emulateJSON : true}).then(function (res) {
                this.list = res.body.data
                console.log(this.list);
            })
        },
        methods:{
            toAddress(event){
                var _th =event.target;
                let id = '';
                let  userAddressName = ''
                if(!$(_th).parents(".container").data("id")){
                    id = $(_th).data("id")
                    userAddressName = $(_th).find('.cont-sp').data("address");
                }else{
                    id = $(_th).parents(".container").data("id")
                    userAddressName = $(_th).find('.cont-sp').data("address");
                }
                // alert(userAddressName);
                if(localStorage.getItem('inTo') == 1){
                    localStorage.setItem('addressId',id)
                    localStorage.setItem('addressName',userAddressName);
                    var usernameadd = localStorage.getItem('userAddressName')
                    // alert(usernameadd);
                    location.href = '../place_order.html'
                    // console.log(1111111);
                    // // localStorage.removeItem('userinfo');
                    // this.$http.post(SURL + '/jfd/usersAddress/selectAddressByAddressId',{addressId:id},{emulateJSON : true}).then(function (res) {
                    //     console.log(this.list);
                    // })
                }else {

                }
            },
            AdAddress(){
                location.href = 'addaddress.html'
            },
            tuTo(){
                window.history.go(-1);
                // location.href = 'addaddress.html'
            }

        }
    })
</script>
</body>
</html>
